<template>
    <baseWageDetailView ref="baseWageDetailView" />

    <div class="app-table">
        <div class="app-body">
            <div class="app-search">
                <el-form :inline="true" class="demo-form-inline" v-model="form">
                    <el-form-item label="工资月份">
                        <el-date-picker v-model="form.wageMonth" type="month" value-format="YYYY-MM"
                            placeholder="请选择工资月份">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button class="serach_btn" type="primary" plain @click="onSubmit"
                            @keyup.enter="searchEnter">搜索</el-button>
                    </el-form-item>
                </el-form>
            </div>
            <el-table size="default" :data="list" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column type="index" label="序号" width="80px" />
                <el-table-column prop="wageMonth" label="月份" />
                <el-table-column prop="teacherName" label="人员姓名" />
                <el-table-column prop="teacherNumber" label="人员工号" />
                <!-- <el-table-column prop="teacherWageTypeId" label="工资条目id"/>
                                <el-table-column prop="teacherWageTypeName" label="工资条目名称"/>
                                <el-table-column prop="wageType" label="工资类型id"/>
                                <el-table-column prop="wageTypeName" label="工资类型名称"/>
                                <el-table-column prop="isStatistics" label="是否统计"/> -->
                <el-table-column prop="wages" label="工资金额" />
                <!-- <el-table-column prop="campus" label="校区"/> -->
                <!-- <el-table-column prop="wageStructure" label="工资结构1应发工资、2应扣工资"/> -->
                <!-- <el-table-column prop="uuid" label="uuid"/> -->
                <!-- <el-table-column prop="createTime" label="创建时间"/> -->
                <el-table-column label="操作" width="210px">
                    <template style="display: block" #default="scope">
                        <el-button class="edit_btn" size="small" type="success" @click="editBaseWage(scope.row)">工资明细
                        </el-button>
                    </template>
                </el-table-column>
                <template v-slot:empty>
                    <el-empty description="暂无数据"></el-empty>
                </template>
            </el-table>
            <el-config-provider :locale="locale">
                <el-pagination :total="total" :page-size="limit" :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
                    layout="total, sizes, prev, pager, next, jumper" @size-change="changePageSize"
                    @current-change="changeCurrentPage">
                </el-pagination>
            </el-config-provider>
        </div>
        <bottomView></bottomView>

    </div>
</template>
<script>
import baseWageDetailView from "@/views/baseInfo/BaseWageDetailView.vue";
import bottomView from "@/components/bottom.vue";

import { ElConfigProvider, ElMessageBox, ElMessage } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { httpService } from "@/utils/httpService";
import { Picture as IconPicture, Upload } from "@element-plus/icons-vue";
import { ref } from "vue";

export default {
    name: "BaseWageListView",
    data() {
        return {
            type: 0,
            title: "",
            dialogFormVisible: ref(false),

            page: 0,
            pageSize: 10,
            total: 0,
            limit: 10,
            list: [],
            form: {
                teacherNumber: "",
                teacherName: "",
                teacherWageTypeName: "",
                wageTypeName: "",
                wageMonth: "",
                uuid: "",
            },
        };
    },
    components: {
        bottomView,
        IconPicture,
        ElConfigProvider, baseWageDetailView,
        ElMessageBox,
        ElMessage, Upload
    },
    setup() {
        return {
            locale: zhCn,
        };
    },
    mounted() {
        this.getBaseWageList()
    },
    watch: {

    },
    methods: {
        searchEnter: function (e) {
            // 使用 which 和 keyCode 属性来解决兼容问题
            var keyCode = window.event ? e.keyCode : e.which;
            var val = e.target.value;
            if (keyCode == 13 && val) {
                this.getBaseWageList();
            }
        },
        add() {
            this.$refs.addEditBaseWageView.title = "添加"
            this.$refs.addEditBaseWageView.personnelType = this.type
            this.$refs.addEditBaseWageView.dialogFormVisible = true;
        },
        editBaseWage(obj) {
            this.$refs.baseWageDetailView.title = "工资明细（" + obj.teacherName + '、' + obj.wageMonth + ")";
            this.$refs.baseWageDetailView.getBaseWageList(obj);
            this.$refs.baseWageDetailView.myList = "myList";
            this.$refs.baseWageDetailView.dialogFormVisible = true;
        },

        reloadData() {
            this.page = 1;
            this.getBaseWageList()
        },


        onSubmit() {
            this.getBaseWageList();
        },
        // 每页记录数改变，size：回调参数，表示当前选中的“每页条数”
        changePageSize(size) {
            this.pageSize = size;
            this.limit = size;
            this.getBaseWageList();
        },

        // 改变页码，page：回调参数，表示当前选中的“页码”
        changeCurrentPage(page) {
            this.page = page;
            this.getBaseWageList();
        },
        tableRowClassName({ row, rowIndex }) {
            return "";
        },
        getBaseWageList() {
            httpService(
                "/javaApi/baseWage/myListGroup/" + this.page + "/" + this.pageSize,
                {
                    "wageMonth": this.form.wageMonth == null ? '' : this.form.wageMonth,
                },
                "get"
            ).then((data) => {
                this.list = data.list;
                this.total = data.total;
                this.pageCount = data.pages;
            });
        },
    },
};
</script>
<style scoped>
.el-main {
    padding: 0px;
}

.teacher-content {
    width: 100%;
}

.app-table {
    background: #eff3f5;
    padding: 5px 10px 10px;
    /* width: 100%; */
}

.app-search {
    margin-top: 0px;
}

.app-separator {
    padding-top: 10px;
    padding-bottom: 20px;
    padding-left: 10px;
}

.app-body {
    background: white;
    padding: 20px 20px 10px 20px;
    margin-bottom: 10px;
    text-align: left;
    min-height: calc(100vh - 204px);
    text-align: left;
}

.el-table .warning-row {
    --el-table-tr-bg-color: var(--el-color-warning-lighter);
}

.el-table .success-row {
    --el-table-tr-bg-color: var(--el-color-success-lighter);
}

.el-pagination {
    text-align: center;
    margin-top: 10px;
}

.serach_btn {
    background-color: #007EFF;
    color: #fff;
    border-radius: 8px;
    border: none;
}


.edit_btn {
    background-color: #fff;
    color: #00c78c;
    border: none;
}
</style>
